/**
*      author: Y_Yao
*      created: 2024-11-02 22:34:00
**/

#include<bits/stdc++.h>

using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 50 + 7;
int a[N];
int n;

void solve()
{
    cin >> n;
    int flag = 0;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        if(i >= 2)
        {
            if(abs(a[i] - a[i-1]) == 5 || abs(a[i] - a[i-1]) == 7) continue;
            else
            {
                flag = 1;
            }
        }
    }
    
    if(flag == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}